import java.lang.annotation.*;
import java.lang.reflect.*;

public class Test {
    public static void main(String[] args) throws Exception {
        check(new Person(18));
        check(new Person(180));
    }

    public static void check(Person p) throws Exception {
        for (Field field : p.getClass().getFields()) {
            Check c1 = field.getAnnotation(Check.class);
            if (c1 != null) {
                int min = c1.min();
                int max = c1.max();
                Object instance_value = field.get(p);
                if (instance_value instanceof Integer num) {
                    if (num >= min && num <= max) {
                        System.out.println("数据校验通过！");
                    } else {
                        System.out.println("数据未校验通过！" + "min is " + min + "," + "max is " + max);
                    }
                }
            }
        }
    }
}

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@interface Check {
    int min() default 1;

    int max() default 100;

}

class Person {
    @Check(min = 100, max = 1000)
    public int num;

    public Person(int num) {
        this.num = num;
    }
}